//
//  ZJFingerprintViewController.m
//  ShangHaiHuDongApp
//
//  Created by ZJ on 2017/7/12.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJFingerprintViewController.h"
#import "DWFingerprintUNlock.h"
@interface ZJFingerprintViewController ()

/** 指纹识别图片 */
@property (nonatomic, strong) UIImageView *imgBtu;
/** 指纹识别文字 */
@property (nonatomic, strong) UIButton *textBut;
@end

@implementation ZJFingerprintViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    /**  修改状态栏字体颜色  */
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    /**  修改状态栏字体颜色  */
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImageView * imageView = [[UIImageView alloc] init];
    imageView.contentMode = UIViewContentModeCenter;
    imageView.image = [UIImage imageNamed:@"login_logo"];
    [self.view addSubview:imageView];
    imageView.sd_layout
    .topSpaceToView(self.view, LP_TopHeight + 54 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self.view, 0)
    .rightSpaceToView(self.view, 0)
    .heightIs(110 * [UIScreen zj_screenHScale]);

    
    [self.view addSubview:self.imgBtu];
    [self.view addSubview:self.textBut];
    [self fingerPintUNlock];
}

- (void)fingerPintUNlock{
    __weak typeof(self) weakSelf = self;
    [DWFingerprintUNlock dw_initWithFingerprintUNlockPromptMsg:@"通过Home键验证已有手机指纹" cancelMsg:@"取消" otherMsg:@"其他方式登录" otherClick:^(NSString *otherClick) {
        
    } success:^(BOOL success) {
        [weakSelf.view removeFromSuperview];
        [weakSelf removeFromParentViewController];
    } error:^(NSError *error) {
        
    } errorMsg:^(NSString *errorMsg) {
        
    }];
}



- (UIImageView *)imgBtu{
    if (_imgBtu == nil){
        _imgBtu = [[UIImageView alloc]initWithFrame:CGRectMake(0, [UIScreen zj_screenHeight] * 0.42, [UIScreen zj_screenWith], [UIScreen zj_screenHeight] * 0.1)];
        _imgBtu.userInteractionEnabled = YES;
        _imgBtu.image = [UIImage imageNamed:@"icon_zhiwen"];
     
        _imgBtu.contentMode = UIViewContentModeCenter;
        //单击手势
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(fingerPintUNlock)];
        [_imgBtu addGestureRecognizer:tapGesture];
        
    }
    return _imgBtu ;
}

- (UIButton *)textBut{
    if (_textBut == nil){
        _textBut = [UIButton buttonWithType:UIButtonTypeCustom];
        _textBut.frame = CGRectMake(0, CGRectGetMaxY(self.imgBtu.frame), [UIScreen zj_screenWith], 35);
        [_textBut setTitle:@"点击进行指纹识别" forState:UIControlStateNormal];
        _textBut.titleLabel.font = [UIFont systemFontOfSize: 14 * [UIScreen zj_textFontScale]];
        [_textBut setTitleColor:[UIColor themeColor] forState:UIControlStateNormal];
        [_textBut addTarget:self action:@selector(fingerPintUNlock) forControlEvents:UIControlEventTouchUpInside];
    }
    return _textBut;
}


@end
